|
Construct a cross-report Now let us turn from theory to practice. Let us construct a simple cross-report, which would display employees’ salary during four years. To perform this, we need the "simplecross.db" table, which is available in the FastReport "DEMOS\CROSS\DATA" folder. The table contains data of the following kind:
As usually, let us create a new project in Delphi, put the "TTable," "TfrxDBDataSet," and "TfrxReport" components on the form and set them: Table1: the DatabaseName property value of course must correspond with the path to your folder with FastReport! frxDBDataSet1: For cross-reports construction, one should use the "TfrxCrossObject" component Let us enter the report designer. First of all, connect our data source to the "Report|Data…"menu. Put the "DB cross-tab" object on the report list:
On the designer list the object looks lowly:
All settings are specified with the help of the object editor. Let us call it by double-clicking on the object:
The following items are denoted by figures in the picture: 1 – the drop-down list with available data sources;
As you can see, it is possible to operate here only with the help of the mouse. In our case, it is enough to drag fields from the "2" list to the "4," "5," and "6" lists, as it is shown in the picture. Let us not do anything yet. Close the editor by clicking the "ÎÊ" button
Well, it is exactly what we wanted to receive. Let us continue examining the object. Call the object editor once again. The first thing we want to perform is to modify the titles’ colors and to display "Total" instead of "Grand total." It is very easy to perform when using the bottom editor field (N7 in the picture). Here the cross-table structure is displayed, and it can also be set with the help of the mouse. The active call is displayed with an orange frame:
To change the title color into gray, click on the "Year," "Name," and "Grand Total" objects one after another, and then select the desired color via the
It remains to set a format, where the currency values are displayed. To perform this, in the cross-object editor, click on the "Total" object and the object, representing a cell (with the "0" text) one after another and select the required format by clicking on the
|
||||||||||||